package com.xujc.entity;

import org.springframework.context.annotation.Lazy;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by xujc on 6/16/15.
 */
@Entity
@Table(name = "review", schema = "", catalog = "test")
@Lazy(value = false)
public class ReviewEntity {
    private int mRId;
    private int mDId;
    private int mUId;
    private String mContent;
    private Timestamp mTime;
    private int mFloor;
    private DiscuseEntity mDiscuseByDId;
    private UserEntity mUserByUId;

    @Id
    @Column(name = "r_id")
    @GeneratedValue
    public int getRId() {
        return mRId;
    }

    public void setRId(int RId) {
        mRId = RId;
    }

    @Basic
    @Column(name = "d_id")
    public int getDId() {
        return mDId;
    }

    public void setDId(int DId) {
        mDId = DId;
    }

    @Basic
    @Column(name = "u_id")
    public int getUId() {
        return mUId;
    }

    public void setUId(int UId) {
        mUId = UId;
    }

    @Basic
    @Column(name = "content")
    public String getContent() {
        return mContent;
    }

    public void setContent(String content) {
        mContent = content;
    }

    @Basic
    @Column(name = "time")
    public Timestamp getTime() {
        return mTime;
    }

    public void setTime(Timestamp time) {
        mTime = time;
    }

    @Basic
    @Column(name = "floor")
    public int getFloor() {
        return mFloor;
    }

    public void setFloor(int floor) {
        mFloor = floor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ReviewEntity that = (ReviewEntity) o;

        if (mFloor != that.mFloor) return false;
        if (mContent != null ? !mContent.equals(that.mContent) : that.mContent != null) return false;
        if (mTime != null ? !mTime.equals(that.mTime) : that.mTime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = mContent != null ? mContent.hashCode() : 0;
        result = 31 * result + (mTime != null ? mTime.hashCode() : 0);
        result = 31 * result + mFloor;
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "d_id", referencedColumnName = "d_id", nullable = false,updatable = false,insertable = false)
    public DiscuseEntity getDiscuseByDId() {
        return mDiscuseByDId;
    }

    public void setDiscuseByDId(DiscuseEntity discuseByDId) {
        mDiscuseByDId = discuseByDId;
    }

    @ManyToOne
    @JoinColumn(name = "u_id", referencedColumnName = "u_id", nullable = false,updatable = false,insertable = false)
    public UserEntity getUserByUId() {
        return mUserByUId;
    }

    public void setUserByUId(UserEntity userByUId) {
        mUserByUId = userByUId;
    }
}
